package com.kly.user.rulePolicy.enums;

/**
 * lt    (less than)                    小于
 * le （less than or equal to)          小于等于
 * eq  (equal to)                       等于
 * ne  (not equal to)                   不等于
 * ge  (greater than or equal to)       大于等于
 * gt   (greater  than)                 大于
 * @author linqu
 */
public enum OperationEnum {

    LT("LT", "lt", "小于"),
    LE("LE", "le", "小于等于"),
    EQ("EQ", "eq", "等于"),
    GE("GE", "ge", "大于等于"),
    GT("GT", "gt", "大于"),
    NE("NE", "ne", "不等于");


    private final String type;

    private final String Value;

    private final String description;


    OperationEnum(String type, String value, String description) {
        this.type = type;
        Value = value;
        this.description = description;
    }

    public String getType() {
        return type;
    }

    public String getValue() {
        return Value;
    }

    public String getDescription() {
        return description;
    }


    public static OperationEnum fromType(String type) {
        for (OperationEnum userStatus : values()) {
            if (userStatus.getType().equals(type)) {
                return userStatus;
            }
        }
        throw new IllegalArgumentException("Invalid type: " + type);
    }

    public static OperationEnum transformByName(String name) {
        for (OperationEnum userStatus : values()) {
            if (userStatus.getValue().equalsIgnoreCase(name)) {
                return userStatus;
            }
        }
        throw new IllegalArgumentException("Invalid type: " + name);    }
}
